package com.xl.useAnno;


import com.xl.annotation.MyAnnotation;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Test1 {
    public static void main(String[] args) {
        //test1();
        int a = 1 ; int b =2 ;
        if ((a >0) && (b > 0) ){
            System.out.println("hello");
        }

    }

    private static void test1() {
        Cat cat = new Cat();
        cat.jump();

        //通过反射拿到类上的注解和类中的属性
        MyAnnotation annotation = Cat.class.getAnnotation(MyAnnotation.class);
        String value = annotation.value();
        System.out.println(value);
        int number = annotation.number();
        System.out.println(number);
        //通过反射拿到类中的属性
        Field[] declaredFields = Cat.class.getDeclaredFields();
        for (Field field : declaredFields) {
            String name = field.getName();
            Class<?> type = field.getType();
            System.out.println("字段名:"+name +"---"+"字段类型："+type);
        }
        //通过反射拿到类中的方法
        Method[] declaredMethods = Cat.class.getDeclaredMethods();
        for (Method method : declaredMethods) {
            System.out.println(Cat.class.getName()+"中的方法："+method.getName());
        }

        Field[] fields = Cat.class.getFields();
        Field[] declaredFields1 = Cat.class.getDeclaredFields();
    }
}
